//
// Created by jiangpenghui on 2023/4/14.
//

#ifndef CMAKECXX_NUMSTRINGGEN_H
#define CMAKECXX_NUMSTRINGGEN_H

#include <cstdlib>
#include <string>
#include <stdlib.h>
#include <stdio.h>

#include <algorithm>
#include <list>
#include <iostream>

#include <vector>


using namespace std;


// 谓词，判断条件
bool twice(int ele1, int ele2);

// 查找数组范围内满足上述条件元素
void adjacent_find_test();


void all_of_test();


void clamp_test();

template<typename Type>
class MultValue {
    Type factor;
public:
    MultValue(const Type &value) : factor(value) {
        cout << "create MultValue factor" << factor << endl;
    }

    ~MultValue() {
        cout << "destroy  MultValue " << factor << endl;
    }

    // 重载（）方法
    void operator()(Type &elem) const {
        elem *= factor;
    };
};

class Average {
private:
    long num;
    long sum;
public:
    Average() : num(0), sum(0) {
        cout << "create Average" << endl;
    }

    ~Average() {
        cout << "desorty is num:" << num << " sum:=" << sum << endl;
    }

    void operator()(int elem) {
        num++;
        sum += elem;
    }

    // 类型转换运算符
    operator double() {
        cout << "double() is run" << endl;
        return static_cast<double>(sum) / static_cast<double >(num);
    }


    void drawArr(int size);
};

bool mod_lesser(int ele1, int ele2);

// 一个排序的范围是否包含另一排序范围中的所有元素
void includes_test();


void algorithm_swap();

#endif //CMAKECXX_NUMSTRINGGEN_H
